home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1994 March / Internet Info CD-ROM (Walnut Creek) (March 1994).iso / networking / ip / ka9q / net_des.arc / DESTEST.C < prev    next >
C/C++ Source or Header  |  1988-12-05  |  614b  |  41 lines

  1. #include <stdio.h>
  2. main()
  3. {
  4.     char key[8],work[8];
  5.  
  6.     desinit();
  7.     printf("Ready\n");
  8.     get8(key);
  9.     printf("Setting key: "); put8(key); printf("\n");
  10.     setkey(key);
  11.     printf("Key set\n");
  12.  
  13.     while(!feof(stdin)){
  14.         get8(work);
  15.         printf("Plain: "); put8(work); printf("\n");
  16.         endes(work);
  17.         printf("Cipher: "); put8(work); printf("\n");
  18.         dedes(work);
  19.         printf("Decrypted: "); put8(work); printf("\n");
  20.     }
  21. }
  22. get8(cp)
  23. char *cp;
  24. {
  25.     int i,t;
  26.  
  27.     for(i=0;i<8;i++){
  28.         scanf("%2x",&t);
  29.         *cp++ = t;
  30.     }
  31. }
  32. put8(cp)
  33. char *cp;
  34. {
  35.     int i;
  36.  
  37.     for(i=0;i<8;i++){
  38.         printf("%02x ",*cp++ & 0xff);
  39.     }
  40. }
  41.